package org.arclib.x.gui.themes;

import org.arclib.draw.Color;
import org.arclib.draw.Draw;
import org.arclib.math.Point;
import org.arclib.math.Size;
import org.arclib.x.gui.widgets.ActionType;
import org.lwjgl.opengl.GL11;

public class FreeUniverse extends Theme
{

	/// Draw button FreeUniverse Style
	public void drawButton(ActionType type, boolean focus, Point pos, Size size, Color color)
	{
		drawBorder(type, focus, pos, size, color);
	}

	/// Draw label FreeUniverse Style
	public void drawLabel(ActionType type, boolean focus, Point pos, Size size, Color color)
	{
		drawBorder(type, focus, pos, size, color);
	}

	/// Draw textfield FreeUniverse Style
	public void drawTextField(ActionType type, boolean focus, Point pos, Size size, Color color)
	{
		drawBorder(type, focus, pos, size, color);
	}


	/// draw a nice rectangle border
	private void drawBorder(ActionType type, boolean focus, Point pos, Size size, Color color)
	{
		if (focus)
		{
			GL11.glEnable(GL11.GL_LINE_STIPPLE);
			GL11.glLineStipple(3, (short) 0xAAAA);
		}

		Draw.rectangle(pos, size, color, false);
		
		switch(type)
		{
			case DEFAULT:
				Draw.rectangle(pos.add(new Point(1,1)), size.sub(new Size(2,2)), new Color(0, 50, 0, 150),  true);
			break;

			case MOUSEOVER:
				Draw.rectangle(pos.add(new Point(1, 1)), size.sub(new Size(2, 2)), new Color(0, 100, 0, 150),  true);
			break; 

			case CLICKON:
				Draw.rectangle(pos.add(new Point(1, 1)), size.sub(new Size(2, 2)), new Color(0, 150, 0, 150),  true);
			break; 

			case CLICKOFF:
				Draw.rectangle(pos.add(new Point(1, 1)), size.sub(new Size(2, 2)), new Color(0, 50, 0, 150),  true);
			break; 
		}

		if (focus)
			GL11.glDisable(GL11.GL_LINE_STIPPLE); 
	}
}
